{% extends "base.html" %}
{% block title %}
  {% if item is defined %}Edit{% else %}Post{% endif %} your item
{% endblock %}

{% import 'macros.html' as macros %}

{% block content %}
<form action="/item" method="post">
  {% if item is defined %}
  <input type="hidden" name="id" value="{{ item.key().id()|e }}">
  {% else %}
  {% set item = {} %}
  {% set dummy_item = true %}
  {% endif %}
  <label>title:<input type="text" name="title" value="{{ item.title|e }}"></input></label>
  <label>description:<textarea name="description">{{ item.description|d("", true)|e }}</textarea></label>
  <label>price($):<input type="text" name="price" value="{{ item.price|e }}"></input></label>
  {{ macros.set_token(token) }}
  <input type="submit" value="submit">
</form>

{% if item is defined and dummy_item is not defined %}
<hr>
<form action="/item/delete" method="post">
  <input type="hidden" name="id" value="{{ item.key().id()|e }}">
  {{ macros.set_token(token) }}
  <input type="submit" value="delete this item">
</form>
{% endif %}
{% endblock %}
